package com.tanhua.dubbo.server.controller;

import com.tanhua.common.utils.NoAuthorization;
import com.tanhua.dubbo.server.service.ManagerCommentService;
import com.tanhua.dubbo.server.vo.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
//根据publishId查询评论列表
@RestController
@RequestMapping("manage")//一级路径
public class ManagerCommentController {
    //注入service
    @Autowired
    private ManagerCommentService managerCommentService;

    @NoAuthorization
    @GetMapping("messages/comments")//二级路径
    public ResponseEntity<PageResult> messageCommentsList(@RequestParam("messageID") String messageID,
                                                          @RequestParam(value = "page", defaultValue = "1") Integer page,
                                                          @RequestParam(value = "pagesize", defaultValue = "10") Integer pagesize,
                                                          @RequestParam("sortProp") String sortProp,
                                                          @RequestParam("sortOrder") String sortOrder) {
        //使用managerCommentService调用service中的queryCommentList方法查询评论方法
        PageResult pageResult = managerCommentService.queryCommentList(messageID, page, pagesize, sortProp, sortOrder);
        return ResponseEntity.ok(pageResult);
    }


}

